import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class P57 {
	private static long[] infiniteContinuedFunctionRecursive(long count, long n, long numerator, long denominator) {
		//System.out.println("[" + n + "]" + numerator + "/" + denominator);
		long[] f = null;
		if (n == 1) {
			return Util.addFraction(1, 1, numerator, denominator);
		} else {
			f = Util.addFraction(2, 1, numerator, denominator);	
		}
		 				
				
		//System.out.println(">>>" + Arrays.toString(f));
		
		return infiniteContinuedFunctionRecursive(count, n - 1, f[1], f[0]);
	}
	
	private static long[] infiniteContinuedFunction(long count) {
		return infiniteContinuedFunctionRecursive(count, count, 1, 2);
	}
	
	public static void main1(String[] args) {
		int count = 0;
		for (int i = 1; i <= 31; i++) {
			System.out.println(i);
			long[] x = infiniteContinuedFunction(i);
			System.out.println(Arrays.toString(x));
			if (String.valueOf(x[0]).length() - String.valueOf(x[1]).length() > 0) {
				count++;
			}
		}
		
		System.out.println(count);
	}
	
	public static void main(String[] args) {
		int count = 0;
		List<BigInteger[]> list = new ArrayList<BigInteger[]>();
		
		for (int i = 1; i <= 1000; i++) {
			if (i == 1) {
				list.add(new BigInteger[] {new BigInteger("3"), new BigInteger("2")});
			} else if (i == 2) {
				list.add(new BigInteger[] {new BigInteger("7"), new BigInteger("5")});
			} else {
				BigInteger[] prev = list.get(i - 2);
				BigInteger[] next = new BigInteger[2];
				prev[0] = prev[0].subtract(prev[1]);
				
				next[1] = prev[1].multiply(new BigInteger("2")).add(prev[0]);
				next[0] = prev[1].add(next[1]);
				
				list.add(next);
			}
			
			BigInteger[] l = list.get(i - 1);
			System.out.println(i + ":" + Arrays.toString(l));
			if (l[0].toString().length() - l[1].toString().length() > 0) {
				count++;
			}
		}
		
		System.out.println(count);
	}
}
